/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * warningFrame.java
 *
 * Created on Oct 31, 2011, 6:03:29 PM
 */

package giormi;

import javax.swing.JFrame;
import javax.swing.JTable;

/**
 *
 * @author Ling
 */
public class warningFrame extends javax.swing.JFrame {

    /** Creates new form warningFrame */
    String error;
    JFrame frame;
    public warningFrame(String er, JFrame as) {
        initComponents();
        this.setLocation(440, 240);
        this.setSize(460, 200);
        this.setResizable(false);
        this.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
        error=er;
        frame=as;
        addproduct_productexists.setVisible(false);
        incompletedata.setVisible(false);
        lackofstocks1.setVisible(false);
        nostocks.setVisible(false);
        lackofstocks3.setVisible(false);
        customerexists.setVisible(false);
        updateerror.setVisible(false);
        stockexists.setVisible(false);
        selectproducterror.setVisible(false);
        qtyLabel.setVisible(false);
        stocknumLabel.setVisible(false);

        if(er.compareToIgnoreCase("productexists")==0){
            addproduct_productexists.setVisible(true);
        }
        else if(er.compareToIgnoreCase("invaliddata")==0){
            incompletedata.setVisible(true);
        }
        else if(er.compareToIgnoreCase("lackofstocks")==0){
            lackofstocks1.setVisible(true);
            nostocks.setVisible(true);
            lackofstocks3.setVisible(true);
//            qtyLabel.setText("");
//            stocknumLabel.setText("");
            qtyLabel.setVisible(true);
            stocknumLabel.setVisible(true);
        }
        else if(er.compareToIgnoreCase("customerexists")==0){
            customerexists.setVisible(true);
        }
        else if(er.compareToIgnoreCase("stockexists")==0){
            stockexists.setVisible(true);
        }
        else if(er.compareToIgnoreCase("updateerror")==0){
            updateerror.setVisible(true);
        }
        else if(er.compareToIgnoreCase("selectproducterror")==0){
            selectproducterror.setVisible(true);
        }
 else if (er.compareToIgnoreCase("nostocks")==0){
     nostocks.setVisible(true);
 }
    }

    public warningFrame(String er, JFrame as, String idstock, String qty, JTable table) {
        initComponents();
        this.setLocation(440, 240);
        this.setSize(460, 200);
        this.setResizable(false);
        this.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
        error=er;
        frame=as;
        addproduct_productexists.setVisible(false);
        incompletedata.setVisible(false);
        lackofstocks1.setVisible(false);
        nostocks.setVisible(false);
        lackofstocks3.setVisible(false);
        customerexists.setVisible(false);
        updateerror.setVisible(false);
        stockexists.setVisible(false);
        selectproducterror.setVisible(false);
        qtyLabel.setVisible(false);
        stocknumLabel.setVisible(false);

        if(er.compareToIgnoreCase("lackofstocks")==0){
            lackofstocks1.setVisible(true);
            nostocks.setVisible(true);
            lackofstocks3.setVisible(true);
//            qtyLabel.setText("");
//            stocknumLabel.setText("");
            qtyLabel.setVisible(true);
            stocknumLabel.setVisible(true);
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        qtyLabel = new javax.swing.JLabel();
        stocknumLabel = new javax.swing.JLabel();
        lackofstocks1 = new javax.swing.JLabel();
        nostocks = new javax.swing.JLabel();
        lackofstocks3 = new javax.swing.JLabel();
        selectproducterror = new javax.swing.JLabel();
        stockexists = new javax.swing.JLabel();
        updateerror = new javax.swing.JLabel();
        customerexists = new javax.swing.JLabel();
        addproduct_productexists = new javax.swing.JLabel();
        incompletedata = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Warning!");
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        qtyLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        qtyLabel.setText("<qty>");
        getContentPane().add(qtyLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 130, 30, 10));

        stocknumLabel.setFont(new java.awt.Font("Tahoma", 1, 11));
        stocknumLabel.setText("<stock num>");
        getContentPane().add(stocknumLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 140, 60, 10));

        lackofstocks1.setText("The Stock No. selected cannot satisfy the needs of the order. The");
        getContentPane().add(lackofstocks1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 40, -1, 20));

        nostocks.setText("Process Invalid. No more stocks available.");
        getContentPane().add(nostocks, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 40, 250, 50));

        lackofstocks3.setText("needs of this order. ");
        getContentPane().add(lackofstocks3, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 70, -1, 20));

        selectproducterror.setText("No item selected. Select a product from the table.");
        getContentPane().add(selectproducterror, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, -1, 70));

        stockexists.setText("Process failed. Stock already exists.");
        getContentPane().add(stockexists, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, -1, 70));

        updateerror.setText("No item selected. Select an item from the table to update details.");
        getContentPane().add(updateerror, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, -1, 70));

        customerexists.setText("Process failed. Customer already exists.");
        getContentPane().add(customerexists, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, -1, 70));

        addproduct_productexists.setText("Process failed. Product already exists.");
        getContentPane().add(addproduct_productexists, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, -1, 70));

        incompletedata.setText("Process failed. Incomplete/invalid data.");
        getContentPane().add(incompletedata, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 30, 200, 70));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Button-Warning-icon (1).png"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 30, -1, -1));

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/giormi/sources/Ok-icon.png"))); // NOI18N
        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(340, 100, 90, -1));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
//        if(error.compareToIgnoreCase("lackofstocks")==0){
//            succesFrame succesframe = new successFrame();
//            successframe.setVisible(true);
//        }
//            else {
                frame.setEnabled(true);
                this.setVisible(false);
                this.dispose();
//            }
        
    }//GEN-LAST:event_jButton1ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel addproduct_productexists;
    private javax.swing.JLabel customerexists;
    private javax.swing.JLabel incompletedata;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel lackofstocks1;
    private javax.swing.JLabel lackofstocks3;
    private javax.swing.JLabel nostocks;
    private javax.swing.JLabel qtyLabel;
    private javax.swing.JLabel selectproducterror;
    private javax.swing.JLabel stockexists;
    private javax.swing.JLabel stocknumLabel;
    private javax.swing.JLabel updateerror;
    // End of variables declaration//GEN-END:variables

}
